function out = filter_erosion(img,windowSize)
[rows cols] = size(img);
halfWidth = floor(windowSize/2);
out = zeros(rows, cols);
for col = (halfWidth+1) : cols - halfWidth    
    x1 = col - halfWidth;
    x2= col + halfWidth;
    for row = (halfWidth+1) : rows - halfWidth
        y1 = row - halfWidth;
        y2 = row + halfWidth;
        out(row, col) = min(min(img(y1:y2, x1:x2)));
    end
end
end